﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QuanLyBongDa.HeThongGiaoDien;
using QuanLyBongDa.HeThongLuuTru;
using QuanLyBongDa.HeThongXuLy;

namespace QuanLyBongDa.HeThongLuuTru
{
    class BangXepHang
    {
        public static bool XepHang(BangXepHangDTO xh)
        {
            try
            {
                string sql = "insert into BANGXEPHANG(Ngay,TenDoiBong, Thang, Hoa, Thua, HieuSo, Hang) values ('" + xh.Ngay + "','" + xh.TenDoiBong + "','" + xh.Thang + "','" + xh.Hoa + "','" + xh.Thua + "','" + xh.HieuSo + "','" + xh.Hang + "')";
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }
        public static DataTable BangXepHangDoiBong()
        {
            string sql = "SELECT* FROM BANGXEPHANG";
            return DataAccess.ExecQuery(sql);
        }

        public static bool XoaXepHang(BangXepHangDTO xh)
        {
            try
            {
                string sql = "Delete from BANGXEPHANG where SoThuTu = " + xh.SoThuTu;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool SuaBangXepHang(BangXepHangDTO xh)
        {
            try
            {
                string sql = " Update BANGXEPHANG set Ngay = '" + xh.Ngay + "',TenDoiBong = '" + xh.TenDoiBong + "', Thang = " + xh.Thang + ", Hoa = " + xh.Hoa + ",Thua = " + xh.Thua + ",HieuSo = " + xh.HieuSo + ",Hang = " + xh.Hang + "where STT=" + xh.SoThuTu;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}